Imports Phoenix.DataAccess

Namespace Forms

    Public Class EditBreakForm : Inherits PhoenixFormBase

#Region " Windows Form Designer generated code "

        Private mDate As DateTime

        Public Sub New(ByVal bt As DateTime, ByVal et As DateTime)
            MyBase.New()

            'This call is required by the Windows Form Designer.
            InitializeComponent()

            'Add any initialization after the InitializeComponent() call
            mDate = bt.Date
            teFrom.Time = bt
            teTo.Time = et
        End Sub

        Public Sub New(ByVal BeginTime As DateTime, ByVal EndTime As DateTime, ByVal text As String)
            Me.New(BeginTime, EndTime)
            meComment.Text = text
        End Sub

        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents btnOk As DevExpress.XtraEditors.SimpleButton
        Friend WithEvents Label1 As System.Windows.Forms.Label
        Friend WithEvents Label2 As System.Windows.Forms.Label
        Friend WithEvents teFrom As DevExpress.XtraEditors.TimeEdit
        Friend WithEvents meComment As DevExpress.XtraEditors.MemoEdit
        Friend WithEvents teTo As DevExpress.XtraEditors.TimeEdit
        Friend WithEvents CancelBtn As DevExpress.XtraEditors.SimpleButton
        Friend WithEvents ErrorProvider As System.Windows.Forms.ErrorProvider
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(EditBreakForm))
            Me.teFrom = New DevExpress.XtraEditors.TimeEdit
            Me.btnOk = New DevExpress.XtraEditors.SimpleButton
            Me.meComment = New DevExpress.XtraEditors.MemoEdit
            Me.teTo = New DevExpress.XtraEditors.TimeEdit
            Me.Label1 = New System.Windows.Forms.Label
            Me.Label2 = New System.Windows.Forms.Label
            Me.CancelBtn = New DevExpress.XtraEditors.SimpleButton
            Me.ErrorProvider = New System.Windows.Forms.ErrorProvider
            CType(Me.teFrom.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.meComment.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me.teTo.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'teFrom
            '
            Me.teFrom.EditValue = New Date(2005, 3, 11, 0, 0, 0, 0)
            Me.teFrom.Location = New System.Drawing.Point(56, 8)
            Me.teFrom.Name = "teFrom"
            '
            'teFrom.Properties
            '
            Me.teFrom.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton})
            Me.teFrom.Properties.UseCtrlIncrement = False
            Me.teFrom.Size = New System.Drawing.Size(144, 20)
            Me.teFrom.TabIndex = 4
            '
            'btnOk
            '
            Me.btnOk.Location = New System.Drawing.Point(120, 200)
            Me.btnOk.Name = "btnOk"
            Me.btnOk.TabIndex = 1
            Me.btnOk.Text = "&OK"
            '
            'meComment
            '
            Me.meComment.EditValue = ""
            Me.meComment.Location = New System.Drawing.Point(8, 72)
            Me.meComment.Name = "meComment"
            Me.meComment.Size = New System.Drawing.Size(264, 120)
            Me.meComment.TabIndex = 0
            '
            'teTo
            '
            Me.teTo.EditValue = New Date(2005, 3, 11, 0, 0, 0, 0)
            Me.teTo.Location = New System.Drawing.Point(56, 40)
            Me.teTo.Name = "teTo"
            '
            'teTo.Properties
            '
            Me.teTo.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton})
            Me.teTo.Properties.UseCtrlIncrement = False
            Me.teTo.Size = New System.Drawing.Size(144, 20)
            Me.teTo.TabIndex = 6
            '
            'Label1
            '
            Me.Label1.Location = New System.Drawing.Point(8, 10)
            Me.Label1.Name = "Label1"
            Me.Label1.Size = New System.Drawing.Size(48, 16)
            Me.Label1.TabIndex = 3
            Me.Label1.Text = "From:"
            '
            'Label2
            '
            Me.Label2.Location = New System.Drawing.Point(8, 42)
            Me.Label2.Name = "Label2"
            Me.Label2.Size = New System.Drawing.Size(48, 16)
            Me.Label2.TabIndex = 5
            Me.Label2.Text = "To:"
            '
            'CancelBtn
            '
            Me.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.CancelBtn.Location = New System.Drawing.Point(200, 200)
            Me.CancelBtn.Name = "CancelBtn"
            Me.CancelBtn.TabIndex = 2
            Me.CancelBtn.Text = "&Cancel"
            '
            'ErrorProvider
            '
            Me.ErrorProvider.ContainerControl = Me
            '
            'EditBreakForm
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(282, 232)
            Me.Controls.Add(Me.CancelBtn)
            Me.Controls.Add(Me.Label2)
            Me.Controls.Add(Me.Label1)
            Me.Controls.Add(Me.teTo)
            Me.Controls.Add(Me.meComment)
            Me.Controls.Add(Me.btnOk)
            Me.Controls.Add(Me.teFrom)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
            Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
            Me.MaximizeBox = False
            Me.MinimizeBox = False
            Me.Name = "EditBreakForm"
            Me.Text = "Break/Additional Working Time"
            CType(Me.teFrom.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.meComment.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me.teTo.Properties, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)

        End Sub

#End Region

        Public ReadOnly Property BeginTime() As DateTime
            Get
                Return mDate.Add(teFrom.Time.TimeOfDay)
            End Get
        End Property

        Public ReadOnly Property EndTime() As DateTime
            Get
                Return mDate.Add(teTo.Time.TimeOfDay)
            End Get
        End Property

        Public ReadOnly Property Description() As String
            Get
                Return meComment.Text
            End Get
        End Property

        Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
            If EndTime.Subtract(BeginTime).TotalMinutes <= 0 Then
                ErrorProvider.SetError(teTo, Res.ErrorZeroLengthBreak)
            Else
                DialogResult = DialogResult.OK
                Close()
            End If
        End Sub
    End Class

End Namespace